package com.cuanbobox.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.cuanbobox.constant.CbConstant;

public class CbReceiver extends BroadcastReceiver {
    private CbListener listener;

    public CbReceiver(CbListener listener){
        this.listener=listener;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent.getAction().equals(CbConstant.ACTION)){
            int type = intent.getIntExtra("type", -1);
            if(type==CbConstant.TYPE_INSTALL_APK){
                String strData=intent.getStringExtra("strData");
                listener.installAPK(strData);
            }else if(type==CbConstant.WDS_BEAN){
                listener.wdsImg();
            }else if(type==CbConstant.PPT_BEAN){
                listener.pptImg();
            }else if(type==CbConstant.PPT_END){
                listener.pptEnd();
            }else if(type==CbConstant.PPT_START){
                listener.pptStart();
            }else if(type==CbConstant.PPT_NOTE){
                listener.pptNote();
            }else if(type==CbConstant.PPT_NOWPAGE){
                listener.pptNowPate();
            }else if(type==CbConstant.PC_CONNECTED_SUCCESS){
                listener.pcConnectedSuccess();
            }else if(type==CbConstant.PC_CONNECTED_FAIL){
                listener.pcConnectedFail();
            }else if(type==CbConstant.PC_IP_EMPTY){
                listener.pcIpEmpty();
            }else if(type==CbConstant.NO_SIGNAL){
                listener.noSignal();
            }else if(type==CbConstant.HAVE_SIGNAL){
                listener.haveSignal();
            }
        }
    }

    public interface CbListener{
        void installAPK(String path);
        void wdsImg();
        void pptImg();
        void pptEnd();
        void pptStart();
        void pptNote();
        void pptNowPate();
        void pcConnectedSuccess();
        void pcConnectedFail();
        void pcIpEmpty();
        void noSignal();
        void haveSignal();
    }

}
